﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project.Messaging
{
    /// <summary>
    /// 消息生产者
    /// </summary>
    public class MessageFactory
    {
        /// <summary>
        /// 消息对象
        /// </summary>
        public static IMessageManager Instance
        {
            get
            {
                MessageType messageType;
                if (System.Configuration.ConfigurationManager.AppSettings["MessageType"] == null)
                    messageType = MessageType.Email; //通过配置产生
                else
                    messageType = (MessageType)Enum.Parse(typeof(MessageType), System.Configuration.ConfigurationManager.AppSettings["MessageType"].ToString());

                switch (messageType)
                {
                    case MessageType.Email:
                        return new EmailMessageManager();
                    case MessageType.ShortMessage:
                        throw new NotImplementedException("没实现呢，呵呵");
                    default:
                        throw new ArgumentException("您输入的参数有误");
                }
            }
        }
    }
}
